<template>
  <div class="phone-class">
    <div class="entry-container-inner">
      <div class=" published-form__container">
        <div style="min-height: 500px;background-color: rgb(237, 250, 255);margin-right: auto;margin-left: auto">
          <el-image :src="img" style="width: 100%"></el-image>
          <div style="padding: 20px">
            <el-table :data="tableData" border style="width: 100%">
              <el-table-column align="center" prop="remark" label="案件描述">
              </el-table-column>
              <el-table-column align="center" prop="approvalOpinions" label="审批意见">
                <template slot-scope="scope">
                  <span>{{ scope.row.approvalOpinions |opinionsFilter(approvalOpinions) }}</span>
                </template>
              </el-table-column>
              <el-table-column align="center" prop="feedback" label="反馈意见">
              </el-table-column>
              <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                  <el-button size="mini" type="text"  @click="feedbackAttachmentsList(scope.row)">
                    反馈附件
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
            <el-dialog width="90%"
                title="附件信息"
                       :center="true"
                       :close-on-click-modal="false"
                :visible.sync="dialogVisible">
                  <el-row>
                    <el-col v-for="(item,index) in feedbackAttachments" :key="index" :span="24">
                        <el-image
                            v-show="item.attachmentType==='png'||item.attachmentType==='jpg'||item.attachmentType==='bmp'"
                            style="float: left;width:85%;margin: 10px" :src="uploadUrl+item.fileName"
                            :preview-src-list="srcList"></el-image>
                        <video :src="uploadUrl+item.fileName" style="float: left;height: 330px"
                               v-show="item.attachmentType === 'mp4'||item.attachmentType === 'avi'||item.attachmentType === 'rmvb'"
                               controls="controls"
                               width="30%">
                        </video>
                    </el-col>
                  </el-row>
            </el-dialog>
          </div>
        </div>
      </div>
      <footer class="published text-center with-margin-bottom">
      <!--  <a target="_blank" class="powered-by" style="opacity: 1;">
          <p>
            <i class="gd-icon-logo powered-logo"></i><span>睿博提供技术支持</span>
          </p>
        </a>--></footer>
    </div>
  </div>
</template>

<script>
import {findByOpenId} from "@/api/weixin/dustReport"

import {findByDustReportId} from "@/api/weixin/reportAttachment"

export default {
  name: "indexList",
  data() {
    return {
      img: require('@/assets/image/tupian.png'),
      openid: "10086",
      tableData: [],
      //审批意见
      approvalOpinions: [],
      dialogVisible: false,
      feedbackAttachments: [],
      uploadUrl: process.env.VUE_APP_BASE_API_PIC,
    }
  },
  created() {
    debugger
    this.openid = this.$route.query.openid
    debugger
    this.getDicts("sys_approval_opinions").then(response => {
      this.approvalOpinions = response.data;
    });
  },
  mounted() {
    this.findByOpenId();
  },
  methods: {
    findByOpenId() {
      findByOpenId(this.openid).then(res => {
        console.log(res)
        this.tableData = res.data
      }).catch(err => {

      })
    },
    approvalOpinionsFilter(value) {
      let dataType;
      this.approvalOpinions.forEach(data => {
        if (data.dictValue === value) {
          dataType = data.dictLabel;
        }
      })
      return dataType;
    },
    feedbackAttachmentsList(dustReport) {
      let that = this;
      let dustReportId = dustReport.id;
      findByDustReportId(dustReportId).then(res => {
        const {status, data} = res
        if(""!==data&&data.length>0){

          that.$nextTick(function () {
            that.feedbackAttachments = data;
          })
          that.dialogVisible=true;
        }else{
          that.msgInfo("暂无反馈附件")
        }
      })
    }
  }
}
</script>

<style scoped>

</style>